package labox.innovation.gameserver.model;

import labox.innovation.gameserver.templates.item.L2Item;

/**
 * Get all information from L2ItemInstance to generate ItemInfo.<BR><BR>
 *
 */
public class ItemInfo {
	/** Identifier of the L2ItemInstance */
	private long _objectId;

	/** The L2Item template of the L2ItemInstance */
	private L2Item _item;

	/** The level of enchant on the L2ItemInstance */
	private int _enchant;

	/** The quantity of L2ItemInstance */
	private int _count;

	/** The price of the L2ItemInstance */
	private int _price;

	/** If True the L2ItemInstance is equipped */
	private int _equipped;

	/** The action to do clientside (1=ADD, 2=MODIFY, 3=REMOVE) */
	private int _change;

	private int _time;

	private int _location;

	/**
	 * Get all information from L2ItemInstance to generate ItemInfo.<BR><BR>
	 *
	 */
	public ItemInfo(L2ItemInstance item) {
		if (item == null)
			return;

		// Get the Identifier of the L2ItemInstance
		_objectId = item.getObjectId();

		// Get the L2Item of the L2ItemInstance
		_item = item.getItem();

		// Get the enchant level of the L2ItemInstance
		_enchant = item.getEnchantLevel();

		// Get the quantity of the L2ItemInstance
		_count = item.getCount();

		// Verify if the L2ItemInstance is equipped
		_equipped = item.isEquipped() ? 1 : 0;

		// Get the action to do clientside
		switch (item.getLastChange()) {
			case (L2ItemInstance.ADDED): {
				_change = 1;
				break;
			}
			case (L2ItemInstance.MODIFIED): {
				_change = 2;
				break;
			}
			case (L2ItemInstance.REMOVED): {
				_change = 3;
				break;
			}
			case ( L2ItemInstance.EQUIP_MODIFIED ) :{
				_change = 4;
				break;
			}
		}

		_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -1;
		_location = item.getLocationSlot();

	}

	public ItemInfo(L2ItemInstance item, int change) {
		if (item == null)
			return;

		// Get the Identifier of the L2ItemInstance
		_objectId = item.getObjectId();

		// Get the L2Item of the L2ItemInstance
		_item = item.getItem();

		// Get the enchant level of the L2ItemInstance
		_enchant = item.getEnchantLevel();

		// Get the quantity of the L2ItemInstance
		_count = item.getCount();

		// Verify if the L2ItemInstance is equipped
		_equipped = item.isEquipped() ? 1 : 0;

		// Get the action to do clientside
		_change = change;

		_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -1;

		_location = item.getLocationSlot();

	}

	public long getObjectId() {
		return _objectId;
	}

	public L2Item getItem() {
		return _item;
	}

	public int getEnchant() {
		return _enchant;
	}

	public int getCount() {
		return _count;
	}

	public int getPrice() {
		return _price;
	}

	public int getEquipped() {
		return _equipped;
	}

	public int getChange() {
		return _change;
	}

	public int getTime() {
		return _time;
	}

	public int getLocation() {
		return _location;
	}

}
